﻿/*   
    Copyright (C) 2009 Galaktika Corporation ZAO

    This file is a part of Galaktika.BusinessMonitor
 
    Galaktika.BusinessMonitor is a free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
      
    You should have received a copy of the GNU General Public License
    along with Galaktika.BusinessMonitor.  If not, see <http://www.gnu.org/licenses/>.
  
    If GPL v.3 is not suitable for your products or company,
    Galaktika Corp provides Galaktika.BusinessMonitor under a flexible commercial license
    designed to meet your specific usage and distribution requirements.
    If you have already obtained a commercial license from Galaktika Corp,
    you can use this file under those license terms.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Web;
using System.Xml.Serialization;

namespace Galaktika.BI.Silverlight.ClientApp.Web.DAL
{
    using Galaktika.BI.Silverlight.Controls.Data;

    [XmlRoot(Namespace=Common.Namespace)]
    public class DalRootContainer
    {
        public DalRootContainer()
        {
            m_DataSources = new List<DalDataSource>();
            m_Contexts = new List<DalContext>();
            m_Variables = new List<DalVariable>();
        }

        List<DalContext> m_Contexts;
        [XmlArray]
        [XmlArrayItem(typeof(DalContext))]
        public List<DalContext> Contexts
        {
            get
            {
                return m_Contexts; 
            }
            
        }

        List<DalDataSource> m_DataSources;
        [XmlArray]
        [XmlArrayItem(typeof(DalDataSource))]
        public List<DalDataSource> DataSources
        {
            get
            {
                return m_DataSources;
            }
        }

        List<DalVariable> m_Variables;
        [XmlArray]
        [XmlArrayItem(typeof(DalVariable))]
        public List<DalVariable> Variables
        {
            get
            {
                return m_Variables;
            }
        }

        //List<DalContextWindowBinding> m_WndBinds;
        //[XmlArray]
        //[XmlArrayItem("item", typeof(DalContextWindowBinding))]
        //public List<DalContextWindowBinding> WndBinds
        //{
        //    get
        //    {
        //        return m_WndBinds;
        //    }
        //}

        public string ToXml()
        {
            return XmlUtility.Obj2XmlStr(this, Common.Namespace);
        }

        public static DalRootContainer FromXml(string xml)
        {
            return XmlUtility.XmlStr2Obj<DalRootContainer>(xml);
        }

        public static DalRootContainer FromXml(TextReader reader)
        {
            return XmlUtility.XmlStr2Obj<DalRootContainer>(reader);
        }
    }
}